﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace groep20_festival
{
    public partial class bands : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            /*LinkButton lblInsert = new LinkButton();
            lblInsert.Click +=  new EventHandler(lblInsert_Click);
            ¨*/

            ///<summary>
            /* alleen admin krijgt txt te zien */
            ///</summary>
         
            ((TextBox)GridView1.FooterRow.FindControl("txtnaam")).Visible = User.IsInRole("admin");
            ((TextBox)GridView1.FooterRow.FindControl("txtsoortMuziek")).Visible = User.IsInRole("admin");
            ((TextBox)GridView1.FooterRow.FindControl("txturl2")).Visible = User.IsInRole("admin");
            ((LinkButton)GridView1.FooterRow.FindControl("lblInsert")).Visible = User.IsInRole("admin");

           ///<summary>
           ///jquery voor validatie
           ///</summary>

         ScriptManager.ScriptResourceMapping.AddDefinition("jquery", new ScriptResourceDefinition
            {

                Path = "~/scripts/jquery-1.4.1.min.js",
                DebugPath = "~/scripts/jquery-1.4.1.js",
                CdnPath = "http://ajax.microsoft.com/ajax/jQuery/jquery-1.4.1.min.js",
                CdnDebugPath = "http://ajax.microsoft.com/ajax/jQuery/jquery-1.4.1.js"
            });

        }

        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
           
        }

     /// <summary>
     /// nieuwe waarden invoegen 
     /// </summary>
     /// <param name="sender"></param>
     /// <param name="e"></param>

        protected void lblInsert_Click(object sender, EventArgs e)
        {
            /*
            throw new NotImplementedException();
             */
            SqlDataSource1.InsertParameters["band_naam"].DefaultValue =
                ((TextBox) GridView1.FooterRow.FindControl("txtnaam")).Text;

            SqlDataSource1.InsertParameters["band_soortMuziek"].DefaultValue =
               ((TextBox)GridView1.FooterRow.FindControl("txtsoortmuziek")).Text;

            SqlDataSource1.InsertParameters["band_url"].DefaultValue =
               ((TextBox)GridView1.FooterRow.FindControl("txturl")).Text;

            SqlDataSource1.Insert();
        }
       
        

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
        }

        /// <summary>
        /// datasource voor gridvieuw insert, update, ..
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// 
        protected void EntityDataSource1_Selecting(object sender, EntityDataSourceSelectingEventArgs e)
        {

        }
    }
}